/*
 * Copyright 2016-2021 Pnoker. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.xj.common.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xj.common.bean.constant.Common;
import com.xj.common.valid.Insert;
import com.xj.common.valid.Update;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * 控制信息表
 *
 * @author pnoker
 */
@Document
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ControlInfo implements Serializable {

    private static final long serialVersionUID = 1L;
    @MongoId
    private String id;
    private Long deviceId;
    private String deviceSn;
    private String clientId;
    private Date reqtime;
    private Integer resultcode;
    private String resultmsg;
    private String controlmsg;
    private Date resptime;
    private String topic;
    @Transient
    private String MsgType;
    @Transient
    private Integer timeOut = 30;//控制超时时间
    @Transient
    private Integer clearTime = 15;//控制数据存放在redis中的时间数值参数 默认15分钟
    @Transient
    private TimeUnit timeUnit =TimeUnit.MINUTES;//控制数据存放在redis中的时间单位

    public ControlInfo(){

    }
    public ControlInfo(Long deviceId, String clientId, Integer resultcode, String controlmsg) {
        super();
        this.deviceId = deviceId;
        this.clientId = clientId;
        //this.reqtime = reqtime;
        this.resultcode = resultcode;
        //this.resultmsg = resultmsg;
        this.controlmsg = controlmsg;
        //this.resptime = resptime;

    }
    public ControlInfo(String  deviceSn, String clientId, Integer resultcode, String controlmsg) {
        super();
        this.deviceSn = deviceSn;
        this.clientId = clientId;
        //this.reqtime = reqtime;
        this.resultcode = resultcode;
        //this.resultmsg = resultmsg;
        this.controlmsg = controlmsg;
        //this.resptime = resptime;

    }
}
